<template>
  <div class="container">
    <el-card>
      <el-table
        :data="purchaseList"
        stripe
        class="table">
        <el-table-column
          prop="vono"
          label="采购单号">
        </el-table-column>
        <el-table-column
          prop="model"
          label="车型">
        </el-table-column>
        <el-table-column
          prop="config"
          label="配置">
        </el-table-column>
        <el-table-column
          prop="color"
          label="颜色">
        </el-table-column>
        <el-table-column
          prop="num"
          label="数量">
        </el-table-column>
        <el-table-column
          prop="price"
          label="总价">
        </el-table-column>
        <el-table-column
          prop="iscommon"
          label="追加">
        </el-table-column>
        <el-table-column
          prop="deal_date"
          label="签署日期">
        </el-table-column>
        <el-table-column
          prop="true_date"
          label="交付日期">
        </el-table-column>
        <el-table-column
          prop="accomplish"
          label="完成">
        </el-table-column>
        <el-table-column>
          <template slot-scope="scope">
            <el-button v-if="scope.row.accomplish!=='已完成'" @click="deliver(scope.row.vono)">确认交付</el-button>
            <el-button v-if="scope.row.accomplish==='已完成'" disabled>交付完毕</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: "PurchaseTable",
    props:{
      /*库存列表*/
      purchaseList:[],
    },
    data(){
      return{
      }
    },
    methods:{
      deliver(param){
        this.$confirm('是否确认交付订单？','交付',{
          confirmButtonText:'确定',
          cancelButtonText:'取消',
          type:'warning'
        }).then(() =>{
          let mydata={
            vono:param,
          }
          console.log(mydata);
          this.$axios.post('/over_vorder',mydata).then((res)=>{
            if(res.data==='1'){
              this.$message({
                type: 'success',
                message: '订单交付成功!'
              });
              this.$emit("delivered");
              console.log('emitted');
            }else {
              this.$message({
                type: 'error',
                message: '交付失败!'
              });
            }
          })
        })
      }
    },
  }
</script>

<style scoped>

</style>
